package com.aigou.admin.controller;

import com.aigou.admin.annotation.ResponseResult;
import com.aigou.admin.entity.dto.LoginDto;
import com.aigou.admin.entity.vo.ResponseVo;
import com.aigou.admin.entity.User;
import com.aigou.admin.service.UserService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Hor
 * @Date: 2024/12/3 17:12
 * @Version: 1.0
 */
@RestController
@RequestMapping("/login")
@AllArgsConstructor
@ResponseResult
public class LoginController {

    private final UserService userService;

    @RequestMapping()
    public ResponseVo login(LoginDto loginDto) {
        // 验证用户密码是否正确，登录成功返回用户信息
        User user = userService.login(loginDto.getUserName(), loginDto.getPassWord());
        return ResponseVo.buildSuccess(user);
    }

}
